package team2.arsystem.Utilities;

/*TODO : Remove the hard coding of length restrictions*/
public class Validate {

	
	public static boolean validateUserName(String user)
	{
		/*Username must be at least 4 characters long and at most 10 characters long and must contain only upper or lower case characters*/
	
		boolean validated=true;

		if(user.length()>10 || user.length()<4)
			validated = false;

		if(!(user.matches("^[a-zA-Z]+$")))
			validated = false;

		return validated;
	}

	public static boolean validatePassword(String pwd)
	{
		boolean validated=true;

		/*Password must be at least 5 characters long and must be some combination of upper case, lower case characters and numbers.*/

		if(pwd.length()<=4 || pwd.length()>20)
			validated = false;


		if(pwd.matches("^[a-z]+$"))
			validated = false;


		if(pwd.matches("^[0-9]+$"))
			validated = false;



		if(pwd.matches("^[A-Z]+$"))
			validated = false;


		return validated;
	}

	public static boolean validateName(String name,int minLength)
	{

		/*Name of a member must be at least 2 characters long and at most 15 characters long. Name must contain only upper or lower case characters*/

		boolean validated=true;

		if(!(name.matches("^[a-zA-Z]+$")))
			validated = false;
		
		if(name.length()>15 || name.length()<minLength)
			validated = false;


		return validated;
	}

	/*Mobile number must have only numbers and must be 10 digits in length. This number will be used for sending the SMS reminder. Because, we are using emulators, the mobile number may need to be of length 4 and not 10. */
	public static boolean validateMobileNumber(String number)
	{

		boolean validated=true;

		if(!(number.matches("^[0-9]+$")))
			validated = false;

		if(number.length()!= CommandConstants.mobileNumberLength)
			validated=false;

		return validated;
	}

	/*Description must be at least 4 characters long and at most 100 characters long. Name must contain only upper or lower case characters*/
	public static boolean validateDescription(String desc)
	{

		boolean validated=true;

		if(!(desc.matches("^[a-zA-Z]+$")))
			validated = false;
		
		if(desc.length()>100 || desc.length()<4)
			validated = false;


		return validated;
	}

}
